Release 10.1A: OpenEdge Getting Started:
Database Essentials


Applying the principles of the relational model

The relational model organizes data into tables and lets you create relationships among tables by referencing columns that are common to both—the primary and foreign keys. It is easiest to understand this concept of relationships between tables with a common business example.

A hypothetical business needs to track information about customers and their orders, so the business’ database is expected to include tables as follows:

These are the tables depicted in Figure 1–2.

Figure 1–2: Example of a relational database

Suppose you want to find out which customers ordered ski boots. To gather this data from your database, you must know what item number identifies ski boots and who ordered them. There is no direct relationship between the Item table and the Customer table, so to gather the data you need, you join four tables using their primary/foreign key relationships, following these steps:

  1. Select the Item table row whose Description value equals ski boots. The Item Number value is I1.
  2. Next, locate the Orders that contain Item I1. Because the Order table does not contain Items, you first select the Order-Lines that contain I1, and determine the Orders related to these Order-Lines. Orders 01 and 04 contain Item Number I1.
  3. Now that you know the Order Numbers, you can find out the customers who placed the orders. Select the 01 and 04 orders, and determine the associated customer numbers. They are C1 and C3.
  4. Finally, to determine the names of Customers C1 and C3, select the Customer table rows that contain customer numbers C1 and C3. Don Smith and Jim Cain ordered ski boots.

Figure 1–3 illustrates these steps.

Figure 1–3: Selecting records from related tables

By organizing your data into tables and relating the tables with common columns, you can perform powerful queries. The structures of tables and columns are relatively simple to implement and modify, and the data is consistent regardless of the queries or applications used to access the data. This example shows the primary key values as character data for clarity. A numeric key is better and more efficient.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095